import { createStore } from "vuex";

const TOKEN_KEY = "TOUTIAO_USER";
const store = createStore({
  state: {
    user: JSON.parse(window.localStorage.getItem(TOKEN_KEY)),
  },
  mutations: {
    setUser(state, data) {
      state.user = data;
      window.localStorage.setItem(TOKEN_KEY, JSON.stringify(state.user));
    },
  },
});

export default store;
